package com.controller;

import com.pojo.Result;
import com.pojo.Users;
import com.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/promot")
public class PromotController {

    @Autowired
    private UserService userService;

    @GetMapping("/{email}")
    public Result<String> sendCode(@PathVariable("email") String email) {
        Users user = userService.getByEmail(email);
        if (user == null)
            return Result.error("抱歉，邮箱不存在！");
        userService.sendCode(email);
        System.out.println(email);
        return Result.success("验证码已经发送!请查看邮箱!");
    }
}